<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <p id="p">kkk</p>
    <p name="p">1</p>
    <p name="p">2</p>
    <p name="p">3</p>
    <p name="p">4</p>
    <p class="p5">5</p>
    <button onclick="change()">改变</button>
    <script>
        function change(){
            let index = document.getElementById("p");
            index.innerHTML = "<button>已改变</button>"
            
            let arr = document.getElementsByName("p");
            console.log(arr)
            arr.forEach(function(item,i){
                if(item.innerText == "1"){
                    alert("找到了")
                    item.innerText = "444444";
                }
            })
        }
    </script>
</body>
</html>